<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header">
	<th:block th:include="include :: select2-css" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-faultManage-edit" th:object="${faultManage}">
            <input id="faultId" name="faultId" th:field="*{faultId}"  type="hidden">
			<div class="form-group">	
				<label class="col-sm-3 control-label">品牌名称：</label>
				<div class="col-sm-8">
					<select id="brandId" name="brandId" class="form-control" onchange="selectOnChang()">
						<option th:each="elevatorBrand:${elevatorBrandList}" th:value="${elevatorBrand.brandId}" th:text="${elevatorBrand.brandName}" th:field="*{brandId}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">型号名称：</label>
				<div class="col-sm-8">
					<select id="modelIds" name="modelIds" class="form-control select2-multiple" multiple>
						<option th:each="modelName:${modelNames}" th:text="${modelName}" th:selected="${modelName}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">故障代码：</label>
				<div class="col-sm-8">
					<input id="faultCode" name="faultCode" th:field="*{faultCode}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">故障描述：</label>
				<div class="col-sm-8">
					<input id="faultDescribe" name="faultDescribe" th:field="*{faultDescribe}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">可能原因：</label>
				<div class="col-sm-8">
					<input id="possibleCauses" name="possibleCauses" th:field="*{possibleCauses}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">缺陷元件：</label>
				<div class="col-sm-8">
					<input id="defectiveElement" name="defectiveElement" th:field="*{defectiveElement}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">电梯状态：</label>
				<div class="col-sm-8">
					<input id="elevatorStatus" name="elevatorStatus" th:field="*{elevatorStatus}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">恢复：</label>
				<div class="col-sm-8">
					<input id="recovery" name="recovery" th:field="*{recovery}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">实验：</label>
				<div class="col-sm-8">
					<input id="experiment" name="experiment" th:field="*{experiment}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" row="5" th:field="*{remark}" class="form-control" type="text"></textarea>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
	<th:block th:include="include :: select2-js" />
	<th:block th:include="include :: ztree-js" />
    <script type="text/javascript">
		var prefix = ctx + "business/faultManage";
		$("#form-faultManage-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});

		function selectOnChang(){
			//获取被选中的option标签选项
			var brandId = $.form.selectSelects("brandId");
			$.ajax({
				type: "POST",
				url: ctx + "business/elevatorModel/list",
				data: {
					"brandId": brandId
				},
				success: function(result) {
					if (result.code == web_status.SUCCESS) {
						let html = ``;
						result.data.rows.filter(item=>{
							html += `<option value="${item.modelId}"> ${item.modelName}</option>`;
						});
						$("#modelIds").html(html);
					}else {
						$.modal.msgError(result.msg);
					}
				}
			});
		}
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-faultManage-edit').serialize());
	        }
	    }
	</script>
</body>
</html>
